class Event < ActiveRecord::Base
  belongs_to :machine
  has_many :state_transitions
  #  has_many :from_states,:through=>:transition_as_from,:source=>:state
  #  has_one :to_state,:through=>:transitons_as_to,:source=>:state
  accepts_nested_attributes_for :state_transitions
  
  def from_states
    state_transitions.collect{|t|t.from_state}
  end
  def to_state
    state_transitions.collect{|t|t.to_state}.first
  end
end
